package com.oracle.dao.impl;

import java.io.Serializable;
import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.oracle.dao.BaseDao;

public class BaseDaoSupport extends HibernateDaoSupport implements BaseDao {
	@SuppressWarnings("unchecked")
	@Override
	public <T> T save(T t) {
		return (T) this.getHibernateTemplate().save(t);
	}
	@Override
	public <T> void update(T t) {
		this.getHibernateTemplate().update(t);
	}

	@Override
	public <T> void delete(T t) {
		this.getHibernateTemplate().delete(t);
	}

	@Override
	public <T> T getById(Class<T> cls,Serializable id) {
		return this.getHibernateTemplate().get(cls, id);
	}
	
	@Override
	public <T> T loadById(Class<T> cls, Serializable id) {
		return this.getHibernateTemplate().load(cls, id);
	}
	@SuppressWarnings("unchecked")
	@Override
	public <T> List<T> getAll(Class<T> cls) {
		return (List<T>)this.getHibernateTemplate().find("from "+cls.getSimpleName());
	}
	
	
}
